//
//  QuizAppDelegate.h
//  Quiz
//
//  Created by AnhLH-Oriolus on 25/07/2011.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>


@class QuizAppDelegate;
@class MainController;


#define documentPath			[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define libraryPath				[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define applicationSupportPath	[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0]
//#define appDataDirectoryPath	[libraryPath stringByAppendingString:@""]

extern QuizAppDelegate *g_AppDelegate;
extern NSString *g_strMainBundlePath;
extern NSMutableDictionary *g_dictSettings;
extern NSString *sName;
extern int iScore;
extern BOOL isUpdate;


@interface QuizAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
	MainController *mainCtrl;
}
-(void)loadSetting;
-(void)saveSetting;

@property (nonatomic, retain) NSString *sName;
@property (nonatomic) int iScore;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) MainController *mainCtrl;


@end

static void animateView(UIView* view ,NSString*transition,NSString *direction,NSTimeInterval duration){
	// Set up the animation
	CATransition *animation = [CATransition animation];
	[animation setDelegate:view];
	// Set the type and if appropriate direction of the transition, 
	if (transition == kCATransitionFade) {
		[animation setType:kCATransitionFade];
	} else {
		[animation setType:transition];
		[animation setSubtype:direction];
	}	
	// Set the duration and timing function of the transtion -- duration is passed in as a parameter, use ease in/ease out as the timing function
	[animation setDuration:duration];
	[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];	
	[[view layer] addAnimation:animation forKey:@"animationTransition"];
	[[view layer] removeAnimationForKey:@"animationTransition"];
}